/*
    Android UIML

	Copyright (C) 2010  Bram Goffings (bramgoffings@gmail.com)

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public License
	as published by the Free Software Foundation; either version 2.1
	of	the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

package uiml.android.elements;

import java.util.ArrayList;

import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;

public class Constant extends UimlElementWithAttributes{
	
	// TODO comment
	private ArrayList<Constant> childConstants = new ArrayList<Constant>();
	
	// TODO comment
	private String model = null;
	private String value = null;
	
	// TODO comment
	public final String MODEL = "model";
	public final String VALUE = "value";
	public static String IAM = "constant";
	
	/**
	 * 
	 * @param node
	 */
	public Constant(Element node) {
		super(node);
		process();
	}

	/**
	 * 
	 */
	public void processAttributes() {
		super.processAttributes();
		
		NamedNodeMap attributes = node.getAttributes();
		
		if(attributes != null) {
			if(attributes.getNamedItem(MODEL) != null)
				setModel(attributes.getNamedItem(MODEL).getNodeValue());
			else if(attributes.getNamedItem(VALUE) != null)
				setValue(attributes.getNamedItem(VALUE).getNodeValue());
		}
	}
	
	public void processElement(Element elem) {
		
		if(elem.getTagName().equals(Constant.IAM))
			childConstants.add(new Constant(elem));
	}

	/**
	 * @param model the model to set
	 */
	public void setModel(String model) {
		this.model = model;
	}

	/**
	 * @return the model
	 */
	public String getModel() {
		return model;
	}

	/**
	 * @param value the value to set
	 */
	public void setValue(String value) {
		this.value = value;
	}

	/**
	 * @return the value
	 */
	public String getValue() {
		return value;
	}

	/**
	 * @param childConstants the children to set
	 */
	public void setChildren(ArrayList<Constant> m_children) {
		this.childConstants = m_children;
	}

	/**
	 * @return the children
	 */
	public ArrayList<Constant> getChildren() {
		return childConstants;
	}

}
